﻿
define(function (require) {
    var utility = require('utility/utility.js');

    return Backbone.View.extend({
        //... is a list tag.
        tagName: "li",
        template: _.template($("#li_notification").html()),
        events: {

    },
    initialize: function () {
        var $self = this;
        $(this.el).attr('data-theme', 'd')
                  .addClass('ui-btn ui-btn-icon-right ui-li ui-btn-up-d  noti')

        _.bindAll(this, 'render');
        this.model.bind('change', this.render);
        this.model.view = this;
    },
    render: function () {
        var _model = this.model;
        $(this.el).html(this.template(this.model.toJSON()));

        var element = $(this.el)[0];
        var alink = $(element).find('.body').find('.ezlink');
        
        alink.each(function () {
            //去掉连接中的回车 和 一些 带有空内容的连接
            if (this.firstChild.innerHTML == "<br>" || this.firstChild.innerHTML == "") return;
            $(this).addClass('notification-link');

            $(this).appendTo($(element).find(".action-r"));
        })

        $(this.el).find('a.ezlink').each(function (index, item) {
            var feedId = _model.get('FeedId');
            //todo: handle a target
        });

        return this;
    },
    remove: function () {
        $(this.el).remove();
    }
});
});